package com.javaclimb.drug.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javaclimb.drug.entity.Imginfo;
import com.javaclimb.drug.mapper.ImginfoMapper;
import com.javaclimb.drug.mapper.ImginfoMapper;
import com.javaclimb.drug.service.IImginfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户service实现类
 */
@Service
public class ImgInfoServiceImpl extends ServiceImpl<ImginfoMapper, Imginfo> implements IImginfoService {

    @Autowired
    private ImginfoMapper imginfoMapper;

    @Override
    public Page<Imginfo> selectImginfoPage(int pageNum, int pageSize, String param) {
        QueryWrapper<Imginfo> queryWrapper = new QueryWrapper<>();
        if(StringUtils.isNotEmpty(param)){
            queryWrapper.like("type",param);
        }
        Page<Imginfo> page = new Page<>(pageNum,pageSize);
        return imginfoMapper.selectPage(page,queryWrapper);
    }

    @Override
    public int addImginfo(Imginfo imginfo) {
        return imginfoMapper.insert(imginfo);
    }

    @Override
    public int editImginfo(Imginfo imginfo) {
        return imginfoMapper.updateById(imginfo);
    }

    @Override
    public Imginfo queryImginfoById(Integer id) {
        return imginfoMapper.selectById(id);
    }

    @Override
    public int delImginfoById(Integer id) {
        return imginfoMapper.deleteById(id);
    }

    @Override
    public List<Imginfo> queryImginfoList() {
        QueryWrapper<Imginfo> queryWrapper = new QueryWrapper<>();
        return imginfoMapper.selectList(null);
    }
}
